from __future__ import division
import math

# splitting the files for different process.
numOfFilesWantToGenerate = 40
numOfTotalPaths = 67167
numOfPathsInEachFile = math.ceil( numOfTotalPaths / numOfFilesWantToGenerate )

print "numOfPathsInEachFile:",numOfPathsInEachFile
print "numOfPathsHandled:",numOfPathsInEachFile * numOfFilesWantToGenerate

inputFileName = "/data5/team/weijiang/the_new_trip_of_feature_generation/final-all_human_judged_webpage_paths.txt"
inputFileHandler = open(inputFileName,"r")

newFlag = True
partNumber = 0
for index,line in enumerate(inputFileHandler.readlines()):
    if newFlag:
        outputFileName = "/data5/team/weijiang/the_new_trip_of_feature_generation/assignment/final-all_human_judged_webpage_paths" + "_part_%02d" % partNumber
        outputFileHandler = open(outputFileName,"w")
        newFlag = False
    outputFileHandler.write(line)
    
    if (index+1) % numOfPathsInEachFile == 0:
        newFlag = True
        partNumber += 1
        outputFileHandler.close()
    